package old;

import googleSearch.GoogleQuery;
import java.awt.Dimension;
import java.io.IOException;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import org.apache.lucene.index.TermFreqVector;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import clustering.ClusteringAlgorithm;
import clustering.Kmeans2;
import clustering.Kmeans3;
import twitterSearch.SearchTwitter;
import twitterSearch.TwitterLuceneIndex;
import twitterSearch.TwitterLuceneSearch;
import twitter4j.QueryResult;
import twitter4j.Tweet;
import twitter4j.Twitter;
import twitter4j.TwitterException;

public class App extends javax.swing.JFrame {
    
    public static final int MAX_NUM_TERMS_FOR_EXPANSION = 6;
    private Twitter twitter;
    private SearchTwitter twitterSearchEngine;
    private final String lang = "en";
    private Directory directory;
    private TwitterLuceneIndex luceneIndex;
    private TwitterLuceneSearch luceneSearch;
    private TermFreqVector[] vectors;
    private int numVectors;
    private ClusteringAlgorithm kMeans;
    private LinkedList<String> topTerms;
    private GoogleQuery googleSearchEngine;
    private final int TOP_QUANTOS = 2;
    
    public App() throws IOException, TwitterException {
        initComponents();
        this.googleSearchEngine = new GoogleQuery();
        this.twitter = getTwitter();
        this.twitterSearchEngine = new SearchTwitter(twitter);
        this.directory = getFDSDirectory();
        this.luceneIndex = new TwitterLuceneIndex(directory);
    }

    private Directory getFDSDirectory() throws IOException{
        String indexDir = "C:\\index-dir";
        return FSDirectory.getDirectory(indexDir, true);
    }
    
    protected void showResultsList(LinkedList<Tweet> tweetList){
          JFrame resultDialog = new JFrame();
          String[] tweetArr = new String[tweetList.size()];

          for (int i = 0; i < tweetList.size(); i++)
                tweetArr[i] = i + ") " + tweetList.get(i).getFromUser() + ":  "
                        + tweetList.get(i).getText();
          
          JList list = new JList(tweetArr);
          JScrollPane scrollPane = new JScrollPane(list,
                  JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, // vertical bar
                  JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
          resultDialog.add(scrollPane);

          resultDialog.setSize(new Dimension(1100, 320));
          resultDialog.setPreferredSize(new Dimension(1100, 320));
          resultDialog.setLocationRelativeTo(null);
          resultDialog.setVisible(true);
      }
    
    protected JList getResultsJList(LinkedList<Tweet> tweetList){
          String[] tweetArr = new String[tweetList.size()];

          for (int i = 0; i < tweetList.size(); i++)
                tweetArr[i] = i + ") " + tweetList.get(i).getFromUser() + ":  "
                        + tweetList.get(i).getText();
          
          JList list = new JList(tweetArr);
          return list;
      }
        
    protected String getResultsString (LinkedList<Tweet> tweetList){
          String results = new String();
          results = results.concat("TWITTER RESULTS:");

          for (int i = 0; i < tweetList.size(); i++)
                results = results.concat("\n\n" + i + ") " + tweetList.get(i).getFromUser() 
                        + ":  " + tweetList.get(i).getText());          
          return results;
      }
    
    private Twitter getTwitter() throws TwitterException, IOException{
        
        return SearchTwitter.getTwitter();
        
        /*Twitter twitter = new TwitterFactory().getInstance();
        twitter.setOAuthConsumer("jaBct5meAX3L676Tq00HA", "rA7FhUkPrAblbfrjy01sKuIJJKYYh9AGx9pthzd4s");
        RequestToken requestToken = twitter.getOAuthRequestToken();
        AccessToken accessToken = null;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while (null == accessToken) {
          System.out.println("Open the following URL and grant access to your account:");
          System.out.println(requestToken.getAuthorizationURL());
          System.out.print("Enter the PIN(if aviailable) or just hit enter.[PIN]:");
          String pin = br.readLine();
          try{
             if(pin.length() > 0){
               accessToken = twitter.getOAuthAccessToken(requestToken, pin);
             }else{
               accessToken = twitter.getOAuthAccessToken();
             }
          } catch (TwitterException te) {
            if(401 == te.getStatusCode()){
              System.out.println("Unable to get the access token.");
            }else{
              te.printStackTrace();
            }
          }
        }
        return twitter;   */     
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jTextFieldGoogleSearchD = new javax.swing.JTextField();
        jTextFieldGoogleSearch = new javax.swing.JTextField();
        jSeparator1 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaGoogleSearch = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextAreaTwitter = new javax.swing.JTextArea();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextAreaGoogleSearchC1 = new javax.swing.JTextArea();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextAreaGoogleSearchC2 = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldPopCluster1 = new javax.swing.JTextField();
        jTextFieldPopCluster2 = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jComboBoxSimilaridade = new javax.swing.JComboBox();
        jComboBoxClusters = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jButton1.setFont(new java.awt.Font("Tahoma", 1, 13));
        jButton1.setText("Search Google");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("Tahoma", 1, 13));
        jButton2.setText("Search Google Dinamically");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jTextFieldGoogleSearchD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldGoogleSearchDActionPerformed(evt);
            }
        });

        jTextFieldGoogleSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldGoogleSearchActionPerformed(evt);
            }
        });

        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        jTextAreaGoogleSearch.setColumns(20);
        jTextAreaGoogleSearch.setEditable(false);
        jTextAreaGoogleSearch.setRows(5);
        jScrollPane1.setViewportView(jTextAreaGoogleSearch);

        jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        jTextAreaTwitter.setColumns(20);
        jTextAreaTwitter.setEditable(false);
        jTextAreaTwitter.setRows(5);
        jScrollPane2.setViewportView(jTextAreaTwitter);

        jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        jTextAreaGoogleSearchC1.setColumns(20);
        jTextAreaGoogleSearchC1.setEditable(false);
        jTextAreaGoogleSearchC1.setRows(5);
        jScrollPane3.setViewportView(jTextAreaGoogleSearchC1);

        jScrollPane4.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        jTextAreaGoogleSearchC2.setColumns(20);
        jTextAreaGoogleSearchC2.setRows(5);
        jScrollPane4.setViewportView(jTextAreaGoogleSearchC2);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 13));
        jLabel1.setText("Google re-ranking Cluster 1 =>");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 13));
        jLabel3.setText("Google re-ranking Cluster 2 =>");

        jLabel4.setText("Palavra-chave:");

        jTextFieldPopCluster1.setEditable(false);
        jTextFieldPopCluster1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldPopCluster1ActionPerformed(evt);
            }
        });

        jTextFieldPopCluster2.setEditable(false);
        jTextFieldPopCluster2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldPopCluster2ActionPerformed(evt);
            }
        });

        jLabel5.setText("Palavra-chave:");

        jLabel6.setText("Similaridade:");

        jComboBoxSimilaridade.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Cosseno", "Alternativa", "Tanimoto" }));
        jComboBoxSimilaridade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxSimilaridadeActionPerformed(evt);
            }
        });

        jComboBoxClusters.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2", "3" }));
        jComboBoxClusters.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxClustersActionPerformed(evt);
            }
        });

        jLabel7.setText("# Clusters:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 1374, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jTextFieldGoogleSearch, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1158, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jTextFieldPopCluster1, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jTextFieldPopCluster2, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jTextFieldGoogleSearchD, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)
                                    .addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel7)
                                            .addComponent(jLabel6))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jComboBoxClusters, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jComboBoxSimilaridade, 0, 120, Short.MAX_VALUE))))
                                .addGap(12, 12, 12)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1159, Short.MAX_VALUE)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 1159, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 1159, Short.MAX_VALUE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldGoogleSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldGoogleSearchD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBoxSimilaridade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBoxClusters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(14, 14, 14)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldPopCluster1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addGap(6, 6, 6)
                        .addComponent(jTextFieldPopCluster2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(85, 85, 85))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    String googleResults = googleSearchEngine.makeQuery(jTextFieldGoogleSearch.getText());
    jTextAreaGoogleSearch.setText(googleResults);
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    QueryResult q = null;

    try {                      
        java.util.LinkedList<Tweet> tweetsMore = twitterSearchEngine.getListSearchResults(
        jTextFieldGoogleSearchD.getText(), lang);                      
        //showResultsList(tweetsMore);  
        jTextAreaTwitter.setText(this.getResultsString(tweetsMore));
        
        luceneIndex.addTweetsNoBlanks(tweetsMore);
        luceneIndex.analyzeTokens(tweetsMore);   
        
        luceneSearch = new TwitterLuceneSearch (directory);
        vectors = luceneSearch.makeVectors();
        luceneSearch.printVectors();
        numVectors = luceneSearch.getNumVectors(); 
        
        if ( jComboBoxClusters.getSelectedItem().equals("2") )
            kMeans = new Kmeans2(vectors, numVectors, luceneIndex.analyzeString(jTextFieldGoogleSearchD.getText()));
        else
            kMeans = new Kmeans3(vectors, numVectors, luceneIndex.analyzeString(jTextFieldGoogleSearchD.getText()));
        kMeans.run(this.getTipoDistancia(), TOP_QUANTOS);
        jTextFieldPopCluster1.setText(kMeans.getStringPopWordsCluster(1));        
        jTextFieldPopCluster2.setText(kMeans.getStringPopWordsCluster(2));
        
        String googleResults;
        
         if (kMeans.getPopTermsClusterTop1().size() <= App.MAX_NUM_TERMS_FOR_EXPANSION){               
            googleResults = googleSearchEngine.makeQuery(jTextFieldGoogleSearchD.getText() + " " + jTextFieldPopCluster1.getText());
            jTextAreaGoogleSearchC1.setText(googleResults);
         }
         else 
            jTextAreaGoogleSearchC1.setText("Muitos termos para query expansion. Validade da busca comprometida.");
        
         if (kMeans.getPopTermsClusterTop2().size() <= App.MAX_NUM_TERMS_FOR_EXPANSION){               
            googleResults = googleSearchEngine.makeQuery(jTextFieldGoogleSearchD.getText() + " " + jTextFieldPopCluster2.getText());
            jTextAreaGoogleSearchC2.setText(googleResults);
         }
         else 
            jTextAreaGoogleSearchC2.setText("Muitos termos para query expansion. Validade da busca comprometida.");
        
        

    } catch (IOException ex) {
        Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
    } catch (TwitterException e1) {
        JOptionPane.showMessageDialog(null, "Error occurred during search, try again.");
    }
}//GEN-LAST:event_jButton2ActionPerformed

private void jTextFieldGoogleSearchDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldGoogleSearchDActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextFieldGoogleSearchDActionPerformed

private void jTextFieldGoogleSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldGoogleSearchActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextFieldGoogleSearchActionPerformed

private void jTextFieldPopCluster2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldPopCluster2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextFieldPopCluster2ActionPerformed

private void jComboBoxSimilaridadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxSimilaridadeActionPerformed

}//GEN-LAST:event_jComboBoxSimilaridadeActionPerformed

private void jComboBoxClustersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxClustersActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jComboBoxClustersActionPerformed

private void jTextFieldPopCluster1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldPopCluster1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextFieldPopCluster1ActionPerformed

private int getTipoDistancia(){
    int tipoDistancia = 0;
    if(((String) jComboBoxSimilaridade.getSelectedItem()).equalsIgnoreCase("cosseno"))
        tipoDistancia = ClusteringAlgorithm.DISTANCIA_COSSENO;
    else if(((String) jComboBoxSimilaridade.getSelectedItem()).equalsIgnoreCase("alternativa"))
        tipoDistancia = ClusteringAlgorithm.DISTANCIA_ALTERNATIVA;
    else if(((String) jComboBoxSimilaridade.getSelectedItem()).equalsIgnoreCase("tanimoto"))
        tipoDistancia = ClusteringAlgorithm.DISTANCIA_TANIMOTO;
    return tipoDistancia;
}
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(App.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(App.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(App.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(App.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {                    
                    new App().setVisible(true);
                } catch (IOException ex) {
                    Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
                } catch (TwitterException ex) {
                    Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
                }                
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JComboBox jComboBoxClusters;
    private javax.swing.JComboBox jComboBoxSimilaridade;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextArea jTextAreaGoogleSearch;
    private javax.swing.JTextArea jTextAreaGoogleSearchC1;
    private javax.swing.JTextArea jTextAreaGoogleSearchC2;
    private javax.swing.JTextArea jTextAreaTwitter;
    private javax.swing.JTextField jTextFieldGoogleSearch;
    private javax.swing.JTextField jTextFieldGoogleSearchD;
    private javax.swing.JTextField jTextFieldPopCluster1;
    private javax.swing.JTextField jTextFieldPopCluster2;
    // End of variables declaration//GEN-END:variables
}
